using UnityEngine;

namespace Voodoo.Sauce.Core
{
	public static class EnvironmentSettings
	{
		public enum Server
		{
			Tech = 0,
			Staging = 1,
			Dev = 2
		}

		private const string ANALYTICS_SERVER_KEY = "AnalyticsServer";

		private const string PROXY_SERVER_KEY = "ProxyServer";

		internal static bool IsDevelopmentBuild = Debug.isDebugBuild;

		internal static Server GetAnalyticsServer()
		{
			Server fall = (IsDevelopmentBuild ? Server.Staging : Server.Tech);
			return (Server)NintendoPlayerPrefs.GetInt("AnalyticsServer", (int)fall);
		}

		internal static string GetAnalyticsURL(string path)
		{
			return string.Format(path, GetAnalyticsServer());
		}

		internal static void SaveAnalyticsServer(Server server)
		{
			NintendoPlayerPrefs.SetInt("AnalyticsServer", (int)server);
		}

		internal static string GetProxyServer()
		{
			return NintendoPlayerPrefs.GetString("ProxyServer");
		}

		internal static void SaveProxyServer(string proxyServer)
		{
			NintendoPlayerPrefs.SetString("ProxyServer", proxyServer);
		}

		internal static string GetLowerCaseEnvironmentFromServer(Server server)
		{
			switch (server)
			{
			case Server.Tech:
				return "production";
			case Server.Staging:
			case Server.Dev:
				return "sandbox";
			default:
				return "unknown";
			}
		}
	}
}
